package com.eastmoney.tutorial.android.myapp;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MyActivity extends Activity implements View.OnClickListener {
    /**
     * Called when the activity is first created.
     */

    private Button btnLogin;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        btnLogin = (Button) findViewById(R.id.btn1);

        //way1
        /*
        btnLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
               System.out.println("clicked! by way1酷！");

            }
        });
        */

        //way2
        /*
        btnLogin.setOnClickListener(new MyOnClickListner(){
            @Override
            public void onClick(View view) {
                super.onClick(view);
                Toast.makeText(MyActivity.this, "哈哈firing...",Toast.LENGTH_SHORT).show();
            }
        });

        */

        //way3
        btnLogin.setOnClickListener(this);

    }

    @Override
    public void onClick(View view) {
        Log.i("tag","way3");
        Toast.makeText(MyActivity.this, "第三种方式",Toast.LENGTH_SHORT).show();
    }
}

class MyOnClickListner implements View.OnClickListener {

    @Override
    public void onClick(View view) {

        System.out.println("click fired! ");
        view.setAlpha(0.5f);

    }
}
